import { http } from '@/utils/request';
import type { ApiResponse, PaginatedResponse, PaginationParams } from '@/types/http';

// 用户相关接口
export interface User {
  id: number;
  username: string;
  email: string;
  avatar?: string;
  createdAt: string;
}

export interface LoginParams {
  username: string;
    password: string;
    captcha: string;
    uuid: string;
    grant_type: string;
    mailCode: string;
    portalValue: string;
}

export interface LoginResponse {
  token: string;
  user: User;
}

// 登录
export const login = (params: LoginParams) => {
  return http.post<LoginResponse>('/auth/login', params);
};

// 获取用户信息
export const getUserInfo = () => {
  return http.get<User>('/user/info');
};

// 更新用户信息
export const updateUserInfo = (data: Partial<User>) => {
  return http.put<User>('/user/info', data);
};
//获取虚拟机列表
export const getVmListWithProject = (params: PaginationParams) => http.get('/res-mgt-web/hosts/page', params);